﻿@model DLMemberPointMS.Entity.ViewModel.MemCard_ConsumeOrdersViewModel

@{
    Layout = null;
}
@*积分返现页面*@
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <link rel="stylesheet" type="text/css" href="~/layui/css/layui.css" />
    <link rel="stylesheet" type="text/css" href="~/layui/layui-theme-custom.css" />
    <script src="~/layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <script src="~/layui/jquery-3.4.1.js" type="text/javascript" charset="utf-8"></script>
    <title>添加等级</title>
    <style>
        .layui-form-label {
            width: 100px
        }
    </style>

    <script>

        layui.use(['form', 'layer'], function () {
            var form = layui.form
                , layer = layui.layer;
            //查找会员
            //搜索按钮的点击事件
            $('#searhMem').click(function () {
                $("#GavePoint").val("");
                $("#Recash").val("");
                $("#shengyujifen").val("");
                //获取输入框的值
                var txt = $('#MC').val();
                $.post('/ExchangGift/GetMemCardInfo', { idOrPhone: txt }, function (resault) {
                    $("#MC_Name").text(resault.data.MC_Name)
                    $("#CL_LevelName").text(resault.data.CL_LevelName)
                    $("#MC_Point").text(resault.data.MC_Point)
                    $("#MC_TotalMoney").text(resault.data.MC_TotalMoney)
                    $("#MC_ID").text(resault.data.MC_ID);
                    $("#MC_CardID").text(resault.data.MC_CardID)

                    layer.msg(resault.msg);

                })

            })

            //积分返现事件
            function ExMoney(jifen) {
                return jifen * 0.1;
            }
            function SyPoint() {
                return $("#MC_Point").text() - $("#GavePoint").val();
            }
            $("#GavePoint").change(function () {
                //积分值
                $("#Recash").val(ExMoney($("#GavePoint").val()))
                //剩余积分
                $("#shengyujifen").val(SyPoint())
            })

            //马上返现事件
            $('#fanxian').click(function () {
                if ($("#MC_Point").text() == "") {
                    layer.msg("请先查出会员信息！！！");
                    return;
                }
                //获取输入框的值
                var MC_ID = $("#MC_ID").text();//会员编码
                var MC_CardID = $("#MC").val();//会员卡号
           
                var CO_GavePoint = $("#GavePoint").val();//兑换积分

                if (parseInt($("#GavePoint").val()) > parseInt($("#MC_Point").text())) {
                    layer.msg("积分大于当前用户积分不能兑换");
                    $("#GavePoint").attr('value', " ");
                    return;
                };
                $.post('/ConsumeOrders/InsertConsumeOrder', { MC_ID: MC_ID, id: MC_CardID, CO_GavePoint: CO_GavePoint }, function (resault) {
                    layer.msg(resault.msg);

                })
            })
       


        })
    </script>

</head>
<body>
    @using (Html.BeginForm("", "", FormMethod.Post, new { @id = "form" }))
    {
        <fieldset class="layui-elem-field layui-field-title">
            <legend>查找会员</legend>
            <div class="layui-field-box">
                <div class="layui-form-item">
                    <label class="layui-form-label">卡号/手机：</label>
                    <div class="layui-input-inline">

                        <input type="text" name="title" lay-verify="title" autocomplete="off" class="layui-input" id="MC">
                    </div>
                    <button id="searhMem" type="button" class="layui-btn layui-btn layui-btn-sm" style="margin-top: 5px;"><i class="layui-icon">&#xe615;搜索</i></button>
                </div>
                <table class="layui-table" id="MemCaidInfo">
                    <colgroup>
                        <col width="30">
                        <col width="150">
                        <col width="30">
                        <col width="150">
                        <col>
                    </colgroup>
                    <tbody>
                        <tr>
                            @*会员信息*@
                            @*@Html.HiddenFor(model => model.EG_ID);
                                @Html.HiddenFor(model => model.MC_CardID);*@

                            <td>会员姓名:<label id="name"></label></td>
                            <td>
                                <span style="color:red">
                                    <label hidden="hidden" id="MC_ID"></label>
                                    <label hidden="hidden" id="MC_CardID"></label>

                                    <label id="MC_Name"></label>
                                </span>
                            </td>
                            <td>当前等级：</td>
                            <td>
                                <span style="color:blue">
                                    <label id="CL_LevelName"></label>
                                </span>
                            </td>
                        </tr>
                        <tr>
                            <td>当前积分</td>
                            <td>
                                <span style="color:red">
                                    <label id="MC_Point"></label>
                                </span>
                            </td>
                            <td>累计消费：</td>
                            <td>
                                <span style="color:blue">
                                    ￥<label id="MC_TotalMoney">
                                    </label>
                                </span>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </fieldset>

        <fieldset class="layui-elem-field layui-field-title">
            <legend>积分返现</legend>
            <div class="layui-field-box">


                <table class="layui-table">
                    <tbody>
                        <tr>

                            <td>兑换日期：</td>
                            <td>

                                @Html.EditorFor(model => model.CO_CreateTime, new { htmlAttributes = new { @class = "layui-input", @Value = DateTime.Now } })
                            </td>
                        </tr>
                        <tr>
                            <td>兑换积分</td>
                            <td>
                                <input type="number" value="" placeholder="请输入整数" id="GavePoint" class="layui-input" />
                                @*  @Html.EditorFor(model => model.CO_GavePoint, new { htmlAttributes = new { @class = "layui-input" } })*@
                            </td>
                            <td>积分返现：</td>
                            <td>
                                <input type="text" value="" id="Recash" class="layui-input" />

                                @*@Html.EditorFor(model => model.CO_Recash, new { htmlAttributes = new { @class = "layui-input" } })*@
                            </td>
                        </tr>
                        <tr>

                            <td>剩余积分：</td>
                            <td>
                                <input type="text" id="shengyujifen" value="" class="layui-input" />
                            </td>
                        </tr>
                    </tbody>
                </table>

            </div>
        </fieldset>
        <fieldset class="layui-elem-field layui-field-title">
            <legend>说明</legend>
            <div class="layui-field-box">
                在操作过程中，只需输入操作的会员卡号/手机查询对应会员，在输入兑换积分，系统将自动计算。<br />
                在“管理”->“其他设置”中了、可以设置会员积分返现的兑换比例。
            </div>
        </fieldset>
        @*<button id="fanxian" class="layui-btn" lay-submit lay-filter="submitform"> 马上返现</button>*@
        <button id="fanxian" type="button" class="layui-btn layui-btn layui-btn-sm" style="margin-top: 5px;"><i class="layui-icon">马上返现</i></button>


    }

</body>
</html>